package com.example.himalayaproject.find.recommend.RecommendWebActivity;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;

import com.example.himalayaproject.R;
import com.example.himalayaproject.adapter.FindViewpagerAdapter;
import com.example.himalayaproject.find.recommend.fragment.DetailsFragment;
import com.example.himalayaproject.find.recommend.fragment.ProgramFragment;

import java.util.ArrayList;
import java.util.List;

public class RecommendActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recommend);
        initView();
    }

    private void initView() {
        TabLayout tabLayout = (TabLayout) findViewById(R.id.recommend_tablayout);
        ViewPager pager = (ViewPager) findViewById(R.id.recommend_pager);
        List<String> stringList=new ArrayList<>();
        stringList.add("详情");
        stringList.add("节目");
        List<Fragment> fragments = new ArrayList<>();
        fragments.add(new DetailsFragment());
        fragments.add(new ProgramFragment());
        tabLayout.setupWithViewPager(pager);
        FindViewpagerAdapter adapter = new FindViewpagerAdapter(getSupportFragmentManager(),stringList,fragments);
        pager.setOffscreenPageLimit(2);
        pager.setAdapter(adapter);

    }
}
